<template>
    <div class="container" :style="{minHeight: screenHeight}">
      <textarea v-model="commentValue" placeholder="请编辑评论文字（100字以内）" placeholder-style="font-size:28rpx;color:#CCCCCC;" maxlength="100"></textarea>
      <div class="sure-btn" @click="fnSure">
        <p>完成</p>
      </div>
      <!--消息提示-->
      <i-message id="message" />
    </div>
</template>
<script>
  const { $Message } = require('../../../static/iview/base/index');
    export default {
        name: '',
        data(){
            return {
              userInfo:'',   //用户信息
              commentValue:'',   //评论框输入内容
              screenHeight: (Number(wx.getSystemInfoSync().windowHeight)) + 'px',
              id:'',   //签到详情的id
            }
        },
      methods:{
        //提交评论
        fnSure(){
            if(!this.commentValue){
              $Message({
                content: '请输入评论内容',
                type: 'error'
              });
            }
          this.$httpWX.post({
            url: '/comment/insertComment',
            data: {
              signId:this.id,
              content:this.commentValue,
              commentUserId:this.userInfo.id
            }
          }).then(res => {
            if(res.code == 0){
              $Message({
                content: '评论成功',
                type: 'success'
              });
              setTimeout(function () {
                wx.navigateBack({
                  delta: 1
                })
              },2000)
            }
          });
        }
      },
      mounted(){
        this.userInfo = wx.getStorageSync('userInfo'); //获取用户信息
      },
      onShow(){
          this.commentValue = '';
      },
      onLoad: function(options) {
        this.id = options.id;
        this.type = options.type;
      }
    }
</script>

<style>
  .container{
    width: 100%;
    background-color: #F7F7F7;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
  }
  textarea{
    width: 100%;
    height: 320rpx;
    background-color: white;
    border-top: 1rpx solid #EEEEEE;
    font-size: 28rpx;
    box-sizing: border-box;
    padding: 28rpx 40rpx;
    color: #282828;
  }
  .sure-btn{
    width: 88%;
    height:90rpx;
    background:rgba(36,198,138,1);
    border-radius:10rpx;
    margin: 40rpx auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .sure-btn>p{
    font-size: 30rpx;
    font-weight: 400;
    color: white;
  }
</style>
